package com.hunlian.makelove.adapter;

import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.hunlian.makelove.R;
import com.hunlian.makelove.bean.ContactModel;

/**
 * Created by zealjiang on 2016/8/29 18:04.
 * Email: zealjiang@126.com
 */
public class ContactAdapter extends ModelAdapter<ContactModel.BeansBean> {

    private Activity mContext;

    public ContactAdapter(Activity mContext) {
        this.mContext = mContext;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        final MyViewHolder holder;
        if (convertView == null) {
            LayoutInflater inflater = LayoutInflater.from(mContext);
            convertView = inflater.inflate(R.layout.item_contact, null);
            holder = new MyViewHolder();

            holder.tvName = (TextView) convertView.findViewById(R.id.tv_name);
            holder.tvValue = (TextView) convertView.findViewById(R.id.tv_value);

            convertView.setTag(holder);
        } else {
            holder = (MyViewHolder) convertView.getTag();
        }

        ContactModel.BeansBean bean;

        bean = getModel(position);


        holder.tvName.setText(bean.getName());
        holder.tvValue.setText(bean.getValue());

        return convertView;
    }

    class MyViewHolder {
        private TextView tvName;
        private TextView tvValue;
    }

}
